const { successRes, errorRes } = require('../../../utils/responseHandler');
const productService = require('../../../services/productService');
const db = require('../../../config/db');

const searchProduct = async (req, res) => {
    try {
        const { page = 1, pageSize = 10, categoryId, type, productName } = req.query;
        const products = await productService.searchProduct({ page, pageSize, categoryId, type, name: productName });
        successRes(res, products);
    } catch (error) {
        errorRes(res, 500, 'Internal server error', error);
    }
};

const getProductDetail = async (req, res) => {
    try {
        const productId = req.params.id;
        const product = await productService.getProductById(productId);
        successRes(res, product);
    } catch (error) {
        errorRes(res, 500, 'Internal server error', error);
    }
};
module.exports = {
    searchProduct,
    getProductDetail

};
